//
//  SHStartPageViewController.m
//  读读日报
//
//  Created by Shawn on 16/3/3.
//  Copyright © 2016年 Shawn. All rights reserved.
//

#import "SHStartPageViewController.h"

#import "SHTabBarViewController.h"

@interface SHStartPageViewController ()

/**图片*/
@property (weak, nonatomic) UIImageView *imageView;

/** window */
@property (strong, nonatomic) UIWindow *window;

@end

@implementation SHStartPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  
    //创建个UIImageView
    UIImageView * imageView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    
    //接收图片
    UIImage *image = [UIImage imageNamed:@"1.pic"];
    
    //图片设置到imageView上
    imageView.image = image;
    
    //将imageView添加到self.view上
    [self.view addSubview:imageView];
    
    self.imageView = imageView;
    
    //调用animation方法
    [self animation];
    
}


-(void)animation

{
    //创建基本动画
    CABasicAnimation * anima = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
   
    //设置图片的锚点
    self.imageView.layer.anchorPoint = CGPointMake(0.5, 0.5);
  
    //从哪开始执行
    anima.fromValue = @1.0f;
    
    //到哪结束
    anima.toValue = @1.5f;
    
    //执行时长
    anima.duration = 8.0;
    
    //将动画添加到layer上
    [self.imageView.layer addAnimation:anima forKey:@"scale"];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        //移除动画
        [self.imageView removeFromSuperview];
        
        //创建Tabbar控制器
        SHTabBarViewController * tab = [[SHTabBarViewController alloc]init];
        
//        //设置Tabbar属性
//        tab.view.backgroundColor = [UIColor blueColor];
        
        //设置Tabbar为window的根控制器
            //拿到window
        
        NSArray  *array = [[UIApplication sharedApplication] windows];
        
            //遍历数组取出window
        for (UIWindow *window in array) {
            
            window.rootViewController = tab;
           
        }

        
});
    
    
    
    
}

@end
